echo "log：开始安装WPS插件"
target_dir="$HOME/.local/share/Kingsoft/wps/jsaddons" 
target_name="data.xml"
target_file="$target_dir/$target_name"
if [ ! -f "$target_file" ]; then
    echo "log：配置文件不存在，准备创建文件"
    cp $target_name $target_file
    echo "log：创建成功"
    exit 0
fi
echo "log：配置文件存在，准备更新配置文件"
cd $target_dir
# 检查是否存在 节点
if ! grep -q '<jspluginonline url="http://localhost:6789/wps-plugins/hello-et/" debug="" install="http://localhost:63342" type="et" name="hello-wps-local" enable="enable_dev"/>' "$target_name"; then
# 在前插入 
    sed -i '/<\/jsplugins>/i \   <jspluginonline url="http://localhost:6789/wps-plugins/hello-et/" debug="" install="http://localhost:63342" type="et" name="hello-wps-local" enable="enable_dev"/>' "$target_name"
    echo "更新配置成功"
    exit 0
else
    echo "节点已存在，无需更新"
    exit 0
fi